package cn.hrms.service.impl;

import cn.hrms.domain.Employee;
import cn.hrms.domain.PageBean;
import cn.hrms.mapper.EmployeeMapper;
import cn.hrms.service.IEmployeeService;
import cn.hrms.utils.DateUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: @date: 2024/12/18 - 13:33
 * @mail: luxiaoxiao@qq.com
 * @info:
 */
@Service
@RequiredArgsConstructor
public class EmployeeServiceImpl implements IEmployeeService {

	private final EmployeeMapper empMapper;

	@Override
	public PageBean page(Integer page, Integer pageSize) {
		// //1. 设置分页参数
		// 		// PageHelper.startPage(page, pageSize);
		// 		// //2. 执行查询
		// 		// Page<Employee> empPage = empMapper.selectEmployeeList();
		// 		// //3. 封装结果
		// 		// return new PageBean(empPage.getTotal(), empPage.getResult());
		return null;
	}

	/**
	 * 查询员工管理列表
	 *
	 * @param employee 员工管理
	 * @return 员工管理
	 */
	@Override
	public List<Employee> selectEmployeeList(Employee employee) {
		// return employeeMapper.selectEmployeeList(employee); }
		return empMapper.selectEmployeeList(employee);
	}

	/**
	 * 查询员工
	 *
	 * @param empNo 员工主键
	 * @return 员工
	 */
	@Override
	public Employee selectEmployeeByEmpNo(Long empNo) {
		return empMapper.selectEmployeeByEmpNo(empNo);
	}

	/**
	 * 新增员工管理
	 * @param employee 员工管理
	 * @return
	 */
	@Override
	public int insertEmployee(Employee employee) {
		employee.setCreateTime(DateUtils.getNowDate());
		employee.setModifyTime(DateUtils.getNowDate());
		return empMapper.insertEmployee(employee);
	}

	/**
	 * 删除员工管理信息
	 * @param empNo 员工管理主键
	 * @return
	 */
	@Override
	public int deleteEmployeeByEmpNo(Long empNo) {
		return empMapper.deleteEmployeeByEmpNo(empNo);
	}

	/**
	 * 批量删除员工
	 *
	 * @param empNos 需要删除的员工管理主键
	 * @return 结果
	 */
	@Override
	public int deleteEmployeeByEmpNos(Long[] empNos) {
		return empMapper.deleteEmployeeByEmpNos(empNos);
	}

	/**
	 * 修改员工
	 *
	 * @param employee 员工
	 * @return 结果
	 */
	@Override
	public int updateEmployee(Employee employee) {
		return empMapper.updateEmployee(employee);
	}
}
